home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / distutils / tests / support.py < prev    next >
Text File  |  2005-10-18  |  1KB  |  55 lines

  1. """Support code for distutils test cases."""
  2.  
  3. import shutil
  4. import tempfile
  5.  
  6. from distutils import log
  7.  
  8.  
  9. class LoggingSilencer(object):
  10.  
  11.     def setUp(self):
  12.         super(LoggingSilencer, self).setUp()
  13.         self.threshold = log.set_threshold(log.FATAL)
  14.  
  15.     def tearDown(self):
  16.         log.set_threshold(self.threshold)
  17.         super(LoggingSilencer, self).tearDown()
  18.  
  19.  
  20. class TempdirManager(object):
  21.     """Mix-in class that handles temporary directories for test cases.
  22.  
  23.     This is intended to be used with unittest.TestCase.
  24.     """
  25.  
  26.     def setUp(self):
  27.         super(TempdirManager, self).setUp()
  28.         self.tempdirs = []
  29.  
  30.     def tearDown(self):
  31.         super(TempdirManager, self).tearDown()
  32.         while self.tempdirs:
  33.             d = self.tempdirs.pop()
  34.             shutil.rmtree(d)
  35.  
  36.     def mkdtemp(self):
  37.         """Create a temporary directory that will be cleaned up.
  38.  
  39.         Returns the path of the directory.
  40.         """
  41.         d = tempfile.mkdtemp()
  42.         self.tempdirs.append(d)
  43.         return d
  44.  
  45.  
  46. class DummyCommand:
  47.     """Class to store options for retrieval via set_undefined_options()."""
  48.  
  49.     def __init__(self, **kwargs):
  50.         for kw, val in kwargs.items():
  51.             setattr(self, kw, val)
  52.  
  53.     def ensure_finalized(self):
  54.         pass
  55.